import 'package:get/get.dart';
import 'package:homemedia/model/media.dart';
import 'package:homemedia/util/http/http.dart';
import 'package:homemedia/util/log_util.dart';

import 'state.dart';

class HomeLogic extends GetxController {
  final HomeState state = HomeState();

  @override
  void onReady() {
    super.onReady();
    initData();
  }

  initData() async{
    Log.d("init data......");
    var result = await Http.get("/v1/media/library/list", queryParameters: {}, isLoading: false);
    // RxList<MediaLibrary> librarylist = [];
    for (var value in (result as List)) {
      MediaLibrary library = MediaLibrary.fromJson(value as Map<String, dynamic>);
      state.librarylist.add(library);
    }
    // state.librarylist = librarylist;

    update();
  }

  void increase() {
    state.count = ++state.count;
    update();
  }


}
